//
//  WMConstant.swift
//  deWaterMarkingProject
//
//  Created by admin on 2025/9/5.
//

import UIKit
import Photos

///app
struct AppInfo {
    static let infoDictionary = Bundle.main.infoDictionary
    //App 名称
    static let appDisplayName : String = Bundle.main.infoDictionary!["CFBundleDisplayName"] as! String
    // Bundle Identifier
    static let bundleIdentifier : String = "com.gq.sy"
    // App 版本号
    static let appVersion : String = Bundle.main.infoDictionary! ["CFBundleShortVersionString"] as! String
    //Bulid 版本号
    static let buildVersion : String = Bundle.main.infoDictionary! ["CFBundleVersion"] as! String
    //ios 版本
    static let iOSVersion : String = UIDevice.current.systemVersion
    //设备 udid
    static let identifierNumber = UIDevice.current.identifierForVendor
    //设备名称
    static let systemName = UIDevice.current.systemName
    // 设备型号
    static let model = UIDevice.current.model
    //设备区域化型号
    static let localizedModel = UIDevice.current.localizedModel
    static let deviceModel: String = Bundle.main.infoDictionary?["DTPlatformName"] as? String ?? ""
    
}

/// 屏幕的宽
let kScreenWidth = UIScreen.main.bounds.size.width
/// 屏幕的高
let kScreenHeight = UIScreen.main.bounds.size.height
let navigationBarHeight: CGFloat = 44

let statusBarHeight = UIApplication.shared.windows[0].safeAreaInsets.top
/// 导航栏高度
let kNaviBarHieght = (kIsIphoneXScreen == true ? 88.0 : 64.0)
/// 刘海屏底部高度
let kXBottomHeight = (kIsIphoneXScreen == true ? 34.0 : 0)
/// 菜单栏高度
let kTabbarBarHeight = kXBottomHeight + 49.0
/// 刘海屏判断
var kIsIphoneXScreen: Bool {
    guard #available(iOS 11.0, *) else {
        return false
    }
    let isX = UIApplication.shared.windows[0].safeAreaInsets.bottom > 0
    return isX
}
var initAdSuccess = false


//MARK: - 字体
struct AppFont {
    /// 常规体
    static let regular = "PingFangSC-Regular"
    /// 中黑体
    static let medium = "PingFangSC-Medium"
    /// 中粗体
    static let smemibold = "PingFangSC-Semibold"
}

struct UserDefaultsKey {
    
    static let domain = "domainKey"
    static let loginUserId = "loginUserIdKey"
    static let loginUserToken = "loginUserTokenKey"
    static let loginPhone = "loginPhoneKey"
    static let isMember = "isMember"
    // 用户协议
    static let userProtocol = "userProtocol"
    // 隐私协议
    static let sercurityProtocol = "sercurityProtocol"
    //分享
    static let shareContent = "shareContent"
    static let shareTitle = "shareTitle"
    static let shareUrl = "shareUrl"
    static let loginUserAvatar = "loginUserAvatar" //用户头像
    // 用户昵称
    static let loginUserName = "loginUserName"
    
    static let oneKeyPhoneTokenKey = "oneKeyPhoneTokenKey"
    static let oneKeyPhoneCodeKey = "oneKeyPhoneCodeKey"
    
    // 购买协议
    static let paymentAgree = "paymentAgree"
    // 自动订阅协议
    static let autoAgree = "autoAgree"
    // 展示ad
    static let showad = "showad"
    static let closeAd = "closeAd"
    static let startIcon = "startIcon"
    // 是否显示评星
    static let isShowStarView = "isShowStarView"
    static let paymentId = "paymentId"
    static let payDesc1 = "payDesc1"
    static let payDesc2 = "payDesc2"
    
    static let ssysUrl = "ssysUrl"
    static let helpUrl = "helpUrl"
    static let fixBulletFrame = "fixBulletFrame"
    static let picxyz = "picxyz"
    static let picfree = "picfree"
    static let picslimit = "picslimit"
    static let picsdesc = "picsdesc"
    static let videojc = "videojc"

    static let picxyzTotalUseCount = "picxyzTotalUseCount"
    static let picxyzUseCount = "picxyzUseCount"
    static let picxyzPreUseTime = "picxyzPreUseTime"

    static let haveNetwork = "haveNetwork"
    
    static let isFirstIn = "isFirstIn"

}


/// 获取访问相册的权限
/// - NSPhotoLibraryUsageDescription
/// - Parameter result: 权限结果
 func checkAlbunAuthority(result: @escaping ((_ granted: Bool) -> Void)) {
    let phototAuthorityStatus = PHPhotoLibrary.authorizationStatus()
    DispatchQueue.main.async {
        switch phototAuthorityStatus {
        case .authorized:
            DispatchQueue.main.async {
                result(true)
            }
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization({ (status) in
                DispatchQueue.main.async {
                    result(status == .authorized)
                }
            })
        default:
            DispatchQueue.main.async {
                result(false)
            }
        }
    }
}
